package com.laizhenghua.demo.config;

import com.laizhenghua.demo.constant.ResponseCodeEnum;
import com.laizhenghua.demo.utils.R;
import jakarta.servlet.http.HttpServletRequest;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

@RestControllerAdvice
@Slf4j
public class MvcGlobalExceptionHandler {

    @ExceptionHandler(IllegalArgumentException.class)
    public R handleException(HttpServletRequest request, IllegalArgumentException e){
        log.info("请求路径 {} 参数异常 ", request.getRequestURI(),  e);
        return R.error(ResponseCodeEnum.FAIL.getCode(), ResponseCodeEnum.FAIL.getDesc());
    }
}
